package model;

/**
 * ToLocation is a type of card that moves you to another field.
 * @author Group 20
 *
 */
public class ToLocation extends Move
{
	/**
	 * startBonus is the amount you get if you pass start, unless otherwise specified.
	 * fieldNumber is the field that you are moved to
	 * payment is the amount that is deposited, 0 if you don't get the start bonus, and 4000 if you do get the start bonus.
	 */
	private int startBonus, fieldNumber, payment;
	
	/**
	 * Constructor
	 * @param description: Card description
	 * @param fieldNumber: targeted field's number
	 * @param startBonus: bonus for passing start
	 */
	public ToLocation(String description, int fieldNumber, int startBonus) {
		super(description);
		this.startBonus = startBonus;
		this.fieldNumber = fieldNumber;
		this.payment = 0;
	}
	
	/**
	 * draw is the method that moves the player and deposits the payment
	 */
	@Override
	public boolean draw(Player player) {
		int oldPosition = player.getStandOnField();
		
		if(fieldNumber < oldPosition)
		{
			player.deposit(startBonus);
			this.payment = startBonus;
		}
		else
			this.payment = 0;
		player.setStandOnField(fieldNumber);
		return true;
	}

	/**
	 * toString Method
	 */
	@Override
	public String toString() {
		return "ToLocation [startBonus=" + startBonus + ", fieldNumber="
				+ fieldNumber + super.toString() +"]";
	}

	
}
